package wonder.tools;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>ConfigFactory class.</p>
 *
 * @author u211354
 * @version $Id: $
 */
public class ConfigFactory
{
	private static ConfigFactory instance;
	private final Map<String,Config> configs;

	private ConfigFactory() {
		super(); configs = new HashMap<String,Config>();
	}

	/**
	 * <p>Getter for the field <code>instance</code>.</p>
	 *
	 * @return a {@link wonder.tools.ConfigFactory} object.
	 */
	public static ConfigFactory getInstance() {
		if (instance == null)
			instance = new ConfigFactory();
		return instance;
	}

	/**
	 * <p>getConfig</p>
	 *
	 * @param name a {@link java.lang.String} object.
	 * @return a {@link wonder.tools.Config} object.
	 */
	public Config getConfig(String name) {
		Config config;
		synchronized (this) {
			config = configs.get(name);
			if (config == null) {
				config = new Config();
				configs.put(name, config);
			}
		}
		return config;
	}
}
